package com.J1ay.carsys.dao;

import com.J1ay.carsys.pojo.BowCar;
import com.J1ay.carsys.pojo.Bower;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author J1ay
 * @Date 2021/6/2 18:53
 * @Description
 */

public interface BowerMapper {
    /**
     * @Author J1ay
     * @Date 2021/6/2 19:09
     * @param phone
     * @Description 根据电话号码查找租车人
     * @return
     */
    @Select("select * from bower where phone = #{phone} and status = 1")
    Bower getBowerByPhone(@Param("phone") String phone);

    /**
     * @Author J1ay
     * @Date 2021/6/2 19:11
     * @param
     * @Description 查找所有租车人
     * @return
     */
    @Select("select * from bower where status = 1")
    Bower[] getBowerList();


    /**
     * @Author J1ay
     * @Date 2021/6/2 19:13
     * @param
     * @Description 租车表总数
     * @return
     */
    @Select("select * from bower where status = 0")
    Bower[] checkBowerList();
    /**
     * @Author J1ay
     * @Date 2021/6/2 19:12
     * @param bower
     * @Description 注册租车人
     * @return
     */
    void addBower(@Param("bower") Bower bower);

    /**
     * @Author J1ay
     * @Date 2021/6/2 21:45
     * @param bower
     * @Description 更新租车人信息
     * @return
     */
    void updateBower(@Param("bower") Bower bower);

    /**
     * @Author J1ay
     * @Date 2021/6/2 21:46
     * @param bower
     * @Description 审核租车人信息
     * @return
     */
    void checkBower(@Param("bower") Bower bower);

    /**
     * @Author J1ay
     * @Date 2021/6/2 21:46
     * @param UId,phone
     * @Description 删除租车人信息
     * @return
     */
    @Delete("DELETE FROM bower WHERE (UId is not null and UId = #{UId}) or (phone is not null and phone = #{phone})")
    int deleteBower(@Param("UId") String UId, @Param("phone") String phone);

    /**
     * @Author J1ay
     * @Date 2021/6/2 21:46
     * @param
     * @Description 租车表总数
     * @return
     */
    @Select("select count(*) from bower;")
    int countBower();


}
